﻿Public Class UCDVCungCap

    Private Sub UCDVCungCap_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GridView_Load()
    End Sub

    Sub GridView_Load()
        GControl.DataSource = DonViCungCapBUS.DonViCungCap_Load()
    End Sub
    Function TestInfo() As Boolean
        If txtTendv.Text = "" Or txtSDT.Text = "" Then
            ThongBao.TestInfo()
            Return False
        End If
        Return True
    End Function

    Private Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click
        If Not TestInfo() Then
            Return
        End If
        Dim dv As New DonViCungCapDTO
        'dv.Madv
        dv.Tendv   = txtTendv.Text
        dv.Sdt     = txtSDT.Text
        dv.Diachi = txtDiaChi.Text
        DonViCungCapBUS.DonViCungCap_Insert(dv)
        GridView_Load
    End Sub

    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        If Not TestInfo() Then
            Return
        End If
        If Not ThongBao.Agree Then
            Return
        End If
        Dim dv As New DonViCungCapDTO
        dv.Madv = GView.GetFocusedRowCellDisplayText("MADV")
        dv.Tendv = txtTendv.Text
        dv.Sdt = txtSDT.Text
        dv.Diachi = txtDiaChi.Text
        DonViCungCapBUS.DonViCungCap_Update(dv)
        GridView_Load()
    End Sub

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        If Not ThongBao.Agree Then
            Return
        End If
        Dim dv As New DonViCungCapDTO
        dv.Madv = GView.GetFocusedRowCellDisplayText("MADV")
        DonViCungCapBUS.DonViCungCap_Delete(dv)
        GridView_Load()
    End Sub

    Private Sub GView_RowCellClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs) Handles GView.RowCellClick
        txtmadv.Text = GView.GetFocusedRowCellDisplayText("MADV")
        txtTendv.Text = GView.GetFocusedRowCellDisplayText("TENDV")
        txtSDT.Text = GView.GetFocusedRowCellDisplayText("SDT")
        txtDiaChi.Text = GView.GetFocusedRowCellDisplayText("DIACHI")
        End Sub
End Class
